package com.rjj.wlqq.fullcalendar;

import com.rjj.wlqq.tool.date.DateUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
  * @Title: FullCalendarController
  * @author 任建军
  * @date 2018/12/25 14:39
  * @Description: 日历插件的使用
  * 中文文档 https://www.helloweba.net/javascript/452.html
  */
@RequestMapping(value = "full")
@Controller
public class FullCalendarController {

    private static final String PREFIX = "fullcalendar/";
    @RequestMapping(value = "/index")
    public String index(){
        return PREFIX + "fullCalendar";
    }

    @RequestMapping(value = "/index2")
    public String index2(){
        return PREFIX + "fullcalendar2";
    }

    /**
      * @title: 获取数据
     *   [  //日历显示的事件，数组形式显示的
     *         {
     *             title: 'All Day Event',
     *             start: '2018-11-01',
     *             color:'red'//不同事件不同颜色
     *         },
     *         {
     *             title: 'Long Event',
     *             start: '2018-11-07',
     *             end: '2018-11-10',
     *             colorl:'blue'
     *         }]
     *
     *
     *              map.put("start", DateUtil.format(new Date(),"yyyy-MM-dd"));
     *              如果只有开始时间，那么默认是全天，在前端【全天】这里显示
     *
      */
    @RequestMapping(value = "/getData", method = RequestMethod.POST)
    @ResponseBody
    public List<Map<String, String>> getData(){

       List<Map<String,String>> list = new ArrayList<>();
       Map<String,String> map = new HashMap<>();
       map.put("title", "All Day Event");
       map.put("start", DateUtil.format(new Date(),"yyyy-MM-dd"));
       map.put("color", "red");
       list.add(map);

        Map<String,String> map1 = new HashMap<>();
        map1.put("title", "All Day");
        map1.put("start", DateUtil.format(new Date(),"yyyy-MM-dd"));
        map1.put("end", DateUtil.format(new Date(),"yyyy-MM-dd"));
        map1.put("color", "blue");
        list.add(map1);

        Map<String,String> map2 = new HashMap<>();
        map2.put("title", "day");
        map2.put("start", DateUtil.format(new Date(),"yyy-MM-dd") + " 00:23:23");
        map2.put("end", DateUtil.format(new Date(),"yyy-MM-dd") + " 03:23:23");
        map2.put("color", "#ff0");
        list.add(map2);
       return list;

    }
}
